$tile-type-block-color: $primary !default;
$tile-type-uncle-color: $cyan !default;
$tile-type-reorg-color: $purple !default;
$tile-type-emission-reward-color: $lilac !default;
$tile-type-transaction-color: $blue !default;
$tile-type-contract-call-color: $green !default;
$tile-type-contract-creation-color: $dark-purple !default;
$tile-type-token-transfer-color: $orange !default;
$tile-type-unique-token-color: $orange !default;
$tile-type-unique-token-image-color: $orange !default;
$tile-type-internal-transaction-color: $teal !default;
$tile-type-api-documentation-color: $primary !default;
$tile-type-progress-bar-color: $primary !default;
$tile-status-error-reason: #ff7986 !default;
$tile-status-awaiting-internal-transactions: $warning !default;
$tile-padding: 1rem;
$tile-title-color: #333 !default;
$tile-body-a-color: #5959d8 !default;

@mixin generate-tile-block($prefix, $color, $label-color: false) {
  &#{ $prefix } {
    border-left: 4px solid $color;

    .tile-transaction-type-block {
      a {
        @if ($label-color) {
          color: $label-color;
        } @else {
          color: $color;
        }
      }
    }

    .tile-label {
      @if ($label-color) {
        color: $label-color;
      } @else {
        color: $color;
      }
    }

    .tile-status-label {
      color: inherit;
    }

    .tile-transaction-type-block {
      background-color: rgba($color, 0.1);
      border-bottom: 1px solid $color;
      border-right: 1px solid $color;
      border-top: 1px solid $color;
      color: $color;
    }
  }
}

/*********************************************************************/

.tile-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 2px;
  text-align: center;

  &:last-child {
    margin-bottom: 0;
  }

  &.font-weight-400 {
    font-weight: 400;
  }
}

.tile-transaction-type-block {
  align-items: center;
  bottom: -17px;
  justify-content: center;
  margin-left: -1px;
  margin-top: -34px;
  padding: 0 5px;
  position: relative;

  @include media-breakpoint-down(sm) {
    align-items: flex-start;
    background: none !important;
    border: none !important;
    bottom: auto;
    flex-direction: column !important;
    margin: 0 0 10px;
    padding-left: 1rem;
    top: auto;

    .tile-status-label {
      margin-left: 0 !important;
    }
  }
}

.tile-status-label {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  padding: 0 5px;
}

.tile-transaction-type-block {
  .tile-status-label {
    padding: 0;
  }
}

.tile-bottom {
  @media (max-width: 767px) {
    justify-content: flex-start !important;
  }
}

.tile-bottom-contents {
  background-color: #f6f7f9;
  font-size: 12px;
  line-height: 1.2;
  padding: 0.8rem 1rem;
}

.tile-transactions {
  color: #a3a9b5;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 10px;
  text-align: left;
}

.tile-badge {
  line-height: 1.25rem;
  margin-bottom: 0.1rem;
  padding: 0;
  text-align: center;
  width: 2.5rem;
}

.tile-muted {
  background-color: $gray-100;
  border-left: 1px solid $border-color;
  box-shadow: none;
}

.tile-code {
  border-radius: 4px;
  border: 1px solid $border-color;
  flex-grow: 1;
  font-size: 12px;
  line-height: 1.4rem;
  padding: $tile-padding;
}

.tile-function-response {
  span.function-response-item {
    display: block;
    margin-left: 1rem;

    &:not(:last-of-type)::after {
      content: ",";
    }
  }

  p {
    margin: 0;
  }
}

.tile-image {
  max-height: 140px;
  max-width: 140px;
}

.tile {
  span[data-address-hash] {
    color: $tile-body-a-color;
  }

  a[data-test=token_link] {
    color: $tile-body-a-color;
  }

  .tile-body {
    a {
      color: $tile-body-a-color;
      &:hover {
        span {
          text-decoration: underline;
        }
      }
    }
  }

  .tile-title {
    color: $tile-title-color;
    font-size: 12px;

    &-hash {
      font-weight: 300;
    }

    &-lg {
      color: $body-color;
      font-size: 16px;
    }
  }
  border-radius: 4px;
  border: 1px solid $border-color;
  color: $text-muted;
  flex-grow: 1;
  font-size: 12px;
  line-height: 1.4rem;
  padding: $tile-padding;

  @include generate-tile-block(
    ".tile-type-block",
    $tile-type-block-color,
    darken($tile-type-block-color, 20%)
  );
  @include generate-tile-block(".tile-type-uncle", $tile-type-uncle-color);
  @include generate-tile-block(".tile-type-reorg", $tile-type-reorg-color);
  @include generate-tile-block(
    ".tile-type-emission-reward",
    $tile-type-emission-reward-color
  );
  @include generate-tile-block(
    ".tile-type-transaction",
    $tile-type-transaction-color
  );
  @include generate-tile-block(
    ".tile-type-contract-call",
    $tile-type-contract-call-color
  );
  @include generate-tile-block(
    ".tile-type-contract-creation",
    $tile-type-contract-creation-color
  );
  @include generate-tile-block(
    ".tile-type-token-transfer",
    $tile-type-token-transfer-color
  );
  @include generate-tile-block(
    ".tile-type-unique-token",
    $tile-type-unique-token-color
  );
  @include generate-tile-block(
    ".tile-type-unique-token-image",
    $tile-type-unique-token-image-color
  );
  @include generate-tile-block(
    ".tile-type-internal-transaction",
    $tile-type-internal-transaction-color
  );
  @include generate-tile-block(
    ".tile-type-api-documentation",
    $tile-type-api-documentation-color
  );
  @include generate-tile-block(
    '[class*="status--error"]',
    $tile-status-error-reason
  );
  @include generate-tile-block(
    ".tile-status--awaiting-internal-transactions",
    $tile-status-awaiting-internal-transactions
  );

  &.n-p {
    padding: 0;
  }

  & + & {
    margin-top: 1rem;
  }

  @include media-breakpoint-down(md) {
    margin-bottom: 1rem;

    [data-selector="place-holder"] & {
      min-height: 105px;
    }
  }

  &.tile-type-block {
    max-width: 100%;
    .tile-title {
      font-weight: 700;
      line-height: 1.2;
      margin-bottom: 12px;
      padding: 1rem 1rem 0 1rem;
    }
  }

  &.tile-type-contract-creation {
    .tile-text-highlight {
      text-decoration: underline;
      text-decoration-style: dashed;
    }
  }

  &.tile-type-token {
    border: 1px solid $border-color;
  }

  &.tile-type-token-transfer {
    &-short-name {
      max-width: 45%;
      overflow: hidden;
      text-overflow: ellipsis;
      vertical-align: middle;
    }
  }

  &.tile-type-unique-token-image {
    padding: 0;

    & .tile-content {
      padding: 45px 0;
    }
  }

  &.tile-type-api-documentation {
    background-color: transparent;
    cursor: pointer;
    padding: 15px;
    text-align: left;
    width: 100%;
  }

  /* Progress bar */
  .progress {
    background-color: #f5f6fa;
    border-radius: 2px;
    height: 4px;
    margin-top: 8px;
    width: 120px;

    .progress-bar {
      background-color: $tile-type-progress-bar-color;
      border-radius: 2px;
    }
  }
}

.card-chain-blocks {
  .card-body {
    .col-lg-3 {
      @include media-breakpoint-down(lg) {
        padding-left: 6px;
        padding-right: 6px;
      }
    }
    .tile-type-block {  
      overflow: hidden; 
    }
    .row {
      @include media-breakpoint-down(lg) {
        margin-left: -6px;
        margin-right: -6px;
      }
    }
  }
}

// Loader
.tile-type-loading {
  background-color: #fff;
  padding-top: 30px;
  padding-bottom: 28px;
}

.tile-loader {
  display: inline-block;
  height: 20px;
  width: 100%;
  border-radius: 4px;
  background-color: #f5f6fa;
  overflow: hidden;
  position: relative;
  &:before {
    width: inherit;
    height: inherit;
    content: '';
    position: absolute;
    background: linear-gradient(to right, #f5f6fa 2%, #eee 18%, #f5f6fa 33%);
    animation-duration: 1.7s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
    animation-name: tilePlaceholderAnimate;
    background-size: 1300px;
  }
}

.tile-label-loader {
  height: 14px;
  width: 80px;
}

.tile-address-loader {
  & + .tile-address-loader {
    margin-top: 6px;
  }
}

@keyframes tilePlaceholderAnimate {
  0%{ background-position: -650px 0; }
  100% { background-position: 650px 0; }
}

// Loading Animation

@keyframes playBlockLoadingAnimation {
  0%, 90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

[data-selector="chain-block-list"] {
  .col-lg-3:first-child {
    .tile-type-block-animation {
      animation: playBlockLoadingAnimation 2.1s linear forwards;
    }
  }
}

.fade-up-blocks-chain {
  .tile-type-block {
    position: relative;
  }
  .tile-type-block-animation {
    opacity: 0;
    position: absolute;
    top: -1px;
    left: -4px;
    width: calc(100% + 5px);
    height: calc(100% + 2px);
    background-color: #F6F7F9;
    border-radius: 4px;
    overflow: hidden;
    transition: .24s ease-out;
    border-top: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    pointer-events: none;
    .tile-type-line-up {
      position: absolute;
      bottom: -1px;
      left: 0;
      height: calc(100% + 2px);
      width: 4px;
      background-color: $tile-type-block-color;
      transform: scaleY(0);
      transform-origin: center bottom;
      animation: blockLoaderLine 2s linear forwards;
      z-index: 2;
    }
    &:after {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      width: 1px;
      background-color: #dee2e6;
    }
  }
}

.cube-animation-title {
  font-size: 12px;
  color: #a3a9b5;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.fade-up-blocks-chain:first-child {
  .tile-type-block-animation {
    opacity: 1;
  }
}

@keyframes blockLoaderLine {
  0% {
    transform: scaleY(0);
  }
  100% {
    transform: scaleY(1);
  }
}

$cube-bezier: cubic-bezier(.25,.8,.25,1);
$cube-quantity: 5;

.cube-animation-wrapper {
  width: 560px;
  height: 290px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.26);
  svg {
    width: 50px;
    margin-top: -29px;

    .side {
      fill: $tile-type-block-color;
      opacity: 1;

      &:nth-of-type(2) {
        fill: lighten($tile-type-block-color, 30);
        opacity: 0.5;
      }

      &:nth-of-type(3) {
        fill: lighten($tile-type-block-color, 80);
        opacity: 0.5;
      }
    }
  }

  @while $cube-quantity > 0 {
    .cube-animation-row:nth-of-type(#{$cube-quantity}) {
      left: 25px * $cube-quantity;
      top: 15px * $cube-quantity;
    }
    .cube-animation-column:nth-of-type(#{$cube-quantity}) {
      position: relative;
      top: 14px * $cube-quantity;
      left: 25px * $cube-quantity;
    }
    .cube-animation-column:nth-of-type(#{$cube-quantity}) svg {
      transform: translate3d(0,0,0);
      animation: shrink-expand 2.8s $cube-bezier forwards;
      animation-delay: -0.16s * $cube-quantity;
    }

    $cube-quantity: $cube-quantity - 1;
  }
}

.cube-animation-center {
  position: absolute;
  top: 6%;
  left: 20%;
}

.cube-animation-row {
  display: flex;
  flex-direction: row-reverse;
  position: absolute;
}

.cube-animation-column {
  display: flex;
  flex-direction: column-reverse;
}

@keyframes shrink-expand {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1);
  }
  100% {
    transform: scale(0);
  }
}

.dark-block-loader {
  width: auto;
  height: 15px;
  background-color: #e2e5ec;
  margin-bottom: 5px;
  border-radius: 4px;
}

.dark-theme-applied .dark-block-loader {
  background-color: #313355;
}

.title-with-label {
  display: inline-block;
  vertical-align: middle;
  margin-top: 3px;
  @include media-breakpoint-down(sm) {
    display: inline;
  }
}

.view-original-token-container {
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}

.token-address-mobile {
  @include media-breakpoint-down(sm) {
    display: inline-block;
    word-break: break-all;
    line-height: 20px;
  }
}
